package cn.xtcode.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: xt-code
 * @date: 2025/8/6 16:13
 * @description:
 */
@Configuration
@EnableConfigurationProperties(AliPayConfigProperties.class)
public class AliPayConfig {
    @Bean("alipayClient")
    public AlipayClient alipayClient(AliPayConfigProperties aliPayConfigProperties) {
        return new DefaultAlipayClient(
                aliPayConfigProperties.getGatewayUrl(),
                aliPayConfigProperties.getApp_id(),
                aliPayConfigProperties.getMerchant_private_key(),
                aliPayConfigProperties.getFormat(),
                aliPayConfigProperties.getCharset(),
                aliPayConfigProperties.getAlipay_public_key(),
                aliPayConfigProperties.getSign_type());
    }
}
